package com.cg.controller;

import com.cg.Dto.InsertBarnDto;
import com.cg.Dto.SearchBarnDto;
import com.cg.Dto.UpdateBarnDto;
import com.cg.Dto.UpdateBarnStatus;
import com.cg.entity.Barn;
import com.cg.result.R;
import com.cg.service.BarnService;
import io.swagger.v3.oas.annotations.media.Schema;
import jakarta.annotation.Resource;
import jakarta.validation.Valid;
import lombok.Data;
import org.springframework.web.bind.annotation.*;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author lhy
 * @since 2024-12-26
 */
@RestController
@RequestMapping("/barn")
public class BarnController { @Resource
private BarnService barnService;
@GetMapping("/searchBarnList")
@Schema(description = "获取圈舍信息接口")
    public R<Barn> searchList(@ModelAttribute @Valid SearchBarnDto searchBarnDto)
{
    return barnService.searchList(searchBarnDto);
}
@PostMapping("/insertBarn")
@Schema(description = "新增圈舍接口")
    public R<Barn> insertBarn(@RequestBody @Valid InsertBarnDto insertBarnDto)
{
     return  barnService.insertBarn(insertBarnDto);
}
@PutMapping("/updateBarn")
    @Schema(description = "/根据id修改圈舍")
    private  R<Barn> updateBarn(@RequestBody @Valid UpdateBarnDto updateBarnDto)
{
   return   barnService.updateBarn(updateBarnDto);
}
@PutMapping("/updateStatus")
    @Schema(description = "根据id更新圈舍状态")
    public R<Barn> updateStatus(@RequestBody @Valid UpdateBarnStatus updateBarnStatus)
{
    return  barnService.updateStatus(updateBarnStatus);
}
}
